﻿// JScript 文件
//设备枚举
var enumEBOX_MDF   =	1;	//配线架
var enumEBOX_JJX   =	2;	//交接箱
var enumEBOX_ZDP   =	3;	//ZDP
var enumEBOX_FXH   =	4;	//分线盒
var enumEBOX_IDF   =	5;	//IDF
var enumEBOX_ZPXX  =    6;  //综合配线箱
var enumEBOX_TO    =    7;  //信息插座
var enumEBOX_TPCP  =    8;  //转接集合点
//增加电缆设备类型

var enumECABLE_UNKNOWN =		0;	//未知
var enumECABLE_ZG =				1;	//主干电缆
var enumECABLE_PX =				2;	//配线电缆
var enumECABLE_ZJ =				3;	//中继电缆
var enumECABLE_LL =				4;	//联络电缆
var enumECABLE_WL =	            5;	//五类电缆
var enumECABLE_YY =             6;	//语音电缆
var enumECABLE_CWL =            7;	//超五类电缆
var enumECABLE_SL =             8;	//三类电缆

var brushIdle = "#00ff00";		    //空闲(绿色)
var brushUse = "#0000ff";          //占用(蓝色)
var brushBad = "#ff00ff";		    //坏(红色)

var brushYz = "#ffff80";		    //预占(黄色)
var brushIdleFw = "#808080";		//空闲封网(灰色)

var enumLineState_idle = 3;			//空闲
var enumLineState_used = 5;			//占用
var enumLineState_bad = 8;		    //坏
var enumLineState_preuse = 4;		//预占
var enumLineState_preidle = 0;		//预拆
var enumLineState_reserve = 7;		//预留
var enumLineState_other = 6;		//可疑

/*
function devcol(entno, devtyp, devno, cn, dcn)
{
    this.entno = entno;
    this.devtyp = devtyp;
    this.devno = devno;
    this.cn = cn;
    this.dcn = dcn;
}
*/

//dev
function devmb(div)
{
    //function
    this.setViewMbRange = setViewMbRange;
    this.setDevSpec = setDevSpec;
    this.setModlist = setModlist;
    this.getModfactNo = getModfactNo;
    this.getZColfactNo = getZColfactNo;
    this.getFColfactNo = getFColfactNo;
    this.getZMaxPortColNumByModCol = getZMaxPortColNumByModCol;
    this.getZMaxPortRowNumByModRow = getZMaxPortRowNumByModRow;
    this.getFMaxPortColNumByModCol = getFMaxPortColNumByModCol;
    this.getFMaxPortRowNumByModRow = getFMaxPortRowNumByModRow;
    this.calculatColsizeList = calculatColsizeList;
    this.calculatModsizeList = calculatModsizeList;
    this.getZportcolsize = getZportcolsize;
    this.getZportrowsize = getZportrowsize;
    this.getFportcolsize = getFportcolsize;
    this.getFportrowsize = getFportrowsize;
    this.getZcolsize = getZcolsize;
    this.getZrowsiz = getZrowsiz;
    this.getFcolsize = getFcolsize;
    this.getFrowsiz = getFrowsiz;
    this.calculatModsize = calculatModsize;
    //this.getdcolno = getdcolno;
    this.disp = disp;
    this.getDevHtml = getDevHtml;
    this.getColsHtml = getColsHtml;
    this.getModsHtml = getModsHtml;
    this.dispAMod = dispAMod;
    this.setPortState = setPortState;
    this.getDzColorByPortState = getDzColorByPortState;
    this.getMaxPortNo = getMaxPortNo;
    this.getMinPortNo = getMinPortNo;

    //view propertiy
    this.div = div;

    this.viewleft = 0;
    this.viewtop = 0;
    this.viewwidth = 0;
    this.viewheight = 0;

    this.zcolnum = 0;
    this.zmodnum = 0;
    this.zstartcolno = 0;
    this.zendcolno = 0;
    this.fcolnum = 0;
    this.fmodnum = 0;
    this.fstartcolno = 0;
    this.fendcolno = 0;

    this.leftspace = 2;
    this.rightspace = 2;
    this.topspace = 20;
    this.bottomspace = 2;

    this.modspace = 1;

    this.colnametop = 2;
    this.colnameheight = 16;
    this.colnamesize = 3;

    this.cdlist = null;
    
    this.zmodlist = null;
    this.zcolsizelist = null;
    this.zrowsizelist = null;
    this.zportsize = 8;
    
    this.fmodlist = null;
    this.fcolsizelist = null;
    this.frowsizelist = null;
    this.fportsize = 8;
    
    //this.collist = null;
    
    this.zdevleft = 0;
    this.zdevtop = 0;
    this.zdevwidth = 0;
    this.zdevheight = 0;

    this.fdevleft = 0;
    this.fdevtop = 0;
    this.fdevwidth = 0;
    this.fdevheight = 0;
    
    this.face = true;
    
    //data
    this.cditemlist = null;
    this.devtype = 0;       //设备类型
    this.devmajor = 0;      //设备主类型
    this.devminor = 0;      //设备子类型
    this.devno = 0;         //设备实体号
    this.devbm = "";        //设备编码
}

function setViewMbRange(left, top, width, height)
{
    this.viewleft = left;
    this.viewtop = top;
    this.viewwidth = width;
    this.viewheight = height;
    
    this.zdevleft = this.viewleft;
    this.zdevtop = this.viewtop;
    this.zdevwidth = 0;
    this.zdevheight = 0;

    this.fdevleft = this.viewleft;
    this.fdevtop = this.viewtop;
    this.fdevwidth = 0;
    this.fdevheight = 0;
}

function setDevSpec(zcolnum, zmodnum, zstartcolno, zendcolno, fcolnum, fmodnum, fstartcolno, fendcolno)
{
    this.zcolnum = zcolnum;
    this.zmodnum = zmodnum;
    this.zstartcolno = zstartcolno;
    this.zendcolno = zendcolno;
    this.fcolnum = fcolnum;
    this.fmodnum = fmodnum;
    this.fstartcolno = fstartcolno;
    this.fendcolno = fendcolno;

    this.zmodlist = new Array(this.zcolnum);
    this.zcolsizelist = new Array(this.zcolnum);
    this.zrowsizelist = new Array(this.zmodnum);
    for (var i = 0; i < this.zcolnum; i++)
    {
        this.zmodlist[i] = new Array(this.zmodnum);
        
        for (var j = 0; j < this.zmodnum; j++)
        {
            this.zmodlist[i][j] = new devmod("");
            this.zmodlist[i][j].devtype = this.devtype;
        }
    }
    
    this.fmodlist = new Array(this.fcolnum);
    this.fcolsizelist = new Array(this.fcolnum);
    this.frowsizelist = new Array(this.fmodnum);
    for (var i = 0; i < this.fcolnum; i++)
    {
        this.fmodlist[i] = new Array(this.fmodnum);
        
        for (var j = 0; j < this.fmodnum; j++)
        {
            this.fmodlist[i][j] = new devmod("");
            this.fmodlist[i][j].devtype = this.devtype;
        }
    }
}

function setModlist(devmodlist, /*collist,*/ cdlist)
{
    var modno = 0;
    var colno = 0;
    var factmodno = 0;
    var factcolno = 0;
    this.cdlist = new Array(cdlist.length);
    //this.collist = new Array(collist.length);

    for (var i = 0; i < cdlist.length; i++)
    {
        this.cdlist[i] = new cditem();
        this.cdlist[i].copyfromcd(cdlist[i]);
    }
    
    /*
    for (var i = 0; i < collist.length; i++)
    {
        this.collist[i] = new devcol(collist[i].entno, collist[i].devtyp, collist[i].devno, collist[i].cn, collist[i].dcn);
    }
    */
    
    for (var i = 0; i < devmodlist.length; i++)
    {
        modno = devmodlist[i].BlockNo;
        colno = devmodlist[i].ColNo;

        factmodno = this.getModfactNo(modno);
        if (colno >= this.zstartcolno && colno <= this.zendcolno)
        {
            if (factmodno < this.zmodnum)
            {
                factcolno = this.getZColfactNo(colno);
                this.zmodlist[factcolno][factmodno].copyfrommod(devmodlist[i])
            }
        }
        else if (colno >= this.fstartcolno && colno <=this.fendcolno)
        {
            if (factmodno < this.fmodnum)
            {
                factcolno = this.getFColfactNo(colno);
                this.fmodlist[factcolno][factmodno].copyfrommod(devmodlist[i])
            }
        }
    }
    
    this.calculatColsizeList();
    this.calculatModsizeList();
    
    this.calculatModsize();
    
    for (var i = 0; i < this.zcolnum; i++)
    {
        for (var j = 0; j < this.zmodnum; j++)
        {
            this.zmodlist[i][j].calculatePortsize();
            this.zmodlist[i][j].calculateModsize();
            
            if (this.cdlist != null)
            {
                this.zmodlist[i][j].calculatePortOffset(this.cdlist);
            }
        }
    }
    for (var i = 0; i < this.fcolnum; i++)
    {
        for (var j = 0; j < this.fmodnum; j++)
        {
            this.fmodlist[i][j].calculatePortsize();
            this.fmodlist[i][j].calculateModsize();
            
            if (this.cdlist != null)
            {
                this.fmodlist[i][j].calculatePortOffset(this.cdlist);
            }
        }
    }
    
    if (this.devtype == enumEBOX_MDF)
    {
        for (var i = 0; i < this.cdlist.length; i++)
	    {
		    var pcditem = this.cdlist[i];
    		
            for (var j = 0; j < this.zmodlist[pcditem.colno-1].length; ++j)
            {
                var vMod = this.zmodlist[pcditem.colno-1][j]
                var portnum = vMod.RowNum*vMod.ColNum;
                var startportno = vMod.StartPortNo;
                var endportno = vMod.StartPortNo + portnum - 1;
		        if (pcditem.colno == vMod.ColNo 
		           && ((pcditem.startport >= startportno && pcditem.startport <= endportno) 
		           || (pcditem.endport >= startportno && pcditem.endport <= endportno) 
		           || (startportno >= pcditem.startport && startportno <= pcditem.endport) 
		           || (endportno >= pcditem.startport && endportno <= pcditem.endport)))
		        {
		            for (var i = pcditem.startport; i <= pcditem.endport; i++)
			        {
			            pos = i - startportno;
			            if (pos >= 0)
			            {
			                vMod.portcabletype[pos] = pcditem.cbltype;
			                vMod.portcdnum[i]++;
			            }
			        }
        		    
			        tmpitem = new cditem();
		            tmpitem.copyfromcd(pcditem);
		            vMod.cdlist.push(tmpitem);
		        }
            }
	    }
	}s
}

function getModfactNo(ModNo)
{
    return ModNo-1;
}

function getZColfactNo(ZColNo)
{
    return ZColNo-this.zstartcolno;
}

function getFColfactNo(FColNo)
{
    return FColNo-this.fstartcolno;
}

function getZMaxPortColNumByModCol(ModCol)
{
    var PortNum = 0;
    var Num = 0;
    
    for (var i = 0; i < this.zmodnum; i++)
    {
        Num = this.zmodlist[ModCol][i].ColNum;
        if (PortNum < Num)
            PortNum = Num;
    }
    
    return PortNum;
}

function getZMaxPortRowNumByModRow(ModRow)
{
    var PortNum = 0;
    var Num = 0;
    
    for (var i = 0; i < this.zcolnum; i++)
    {
        Num = this.zmodlist[i][ModRow].RowNum;
        if (PortNum < Num)
            PortNum = Num;
    }
    
    return PortNum;
}

function getFMaxPortColNumByModCol(ModCol)
{
    var PortNum = 0;
    var Num = 0;
    
    for (var i = 0; i < this.fmodnum; i++)
    {
        Num = this.fmodlist[ModCol][i].ColNum;
        if (PortNum < Num)
            PortNum = Num;
    }
    
    return PortNum;
}

function getFMaxPortRowNumByModRow(ModRow)
{
    var PortNum = 0;
    var Num = 0;
    
    for (var i = 0; i < this.fcolnum; i++)
    {
        Num = this.fmodlist[i][ModRow].RowNum;
        if (PortNum < Num)
            PortNum = Num;
    }
    
    return PortNum;
}

function calculatColsizeList()
{
    for (var i = 0; i < this.zcolnum; i++)
    {
        this.zcolsizelist[i] = this.getZMaxPortColNumByModCol(i);
    }
    
    for (var i = 0; i < this.fcolnum; i++)
    {
        this.fcolsizelist[i] = this.getFMaxPortColNumByModCol(i);
    }
}

function calculatModsizeList()
{
    for (var i = 0; i < this.zmodnum; i++)
    {
        this.zrowsizelist[i] = this.getZMaxPortRowNumByModRow(i);
    }
    for (var i = 0; i < this.fmodnum; i++)
    {
        this.frowsizelist[i] = this.getFMaxPortRowNumByModRow(i);
    }
}

function getZportcolsize()
{
    var zportcolsize = 0;
    for (var i = 0; i < this.zcolnum; i++)
    {
        zportcolsize += this.zcolsizelist[i];
    }
    return zportcolsize;
}

function getZportrowsize()
{
    var zportrowsize = 0;
    for (var i = 0; i < this.zmodnum; i++)
    {
        zportrowsize += this.zrowsizelist[i];
    }
    return zportrowsize;
}

function getFportcolsize()
{
    var fportcolsize = 0;
    for (var i = 0; i < this.fcolnum; i++)
    {
        fportcolsize += this.fcolsizelist[i];
    }
    return fportcolsize;
}

function getFportrowsize()
{
    var fportrowsize = 0;
    for (var i = 0; i < this.fmodnum; i++)
    {
        fportrowsize += this.frowsizelist[i];
    }
    return fportrowsize;
}

function getZcolsize(colno)
{
    if (this.zcolnum == 0 || this.zmodnum == 0)
        return 0;
        
    return this.zcolsizelist[colno]*this.zportsize + this.modspace*2 + this.zmodlist[colno][0].border*2;
}

function getFcolsize(colno)
{
    if (this.fcolnum == 0 || this.fmodnum == 0)
        return 0;

    return this.fcolsizelist[colno]*this.fportsize + this.modspace*2 + this.fmodlist[colno][0].border*2;
}

function getZrowsiz(rowno)
{
    if (this.zcolnum == 0 || this.zmodnum == 0)
        return 0;
        
    return this.zrowsizelist[rowno]*this.zportsize + this.modspace*2 + this.zmodlist[0][rowno].border*2;
}

function getFrowsiz(rowno)
{
    if (this.fcolnum == 0 || this.fmodnum == 0)
        return 0;
        
    return this.frowsizelist[rowno]*this.fportsize + this.modspace*2 + this.fmodlist[0][rowno].border*2;
}

function calculatModsize()
{
    var colportnum = 0;
    var rowportnum = 0;

    var portsize = 0;
    var hportsize = 0;
    var vportsize = 0;

    colportnum = this.getZportcolsize();
    rowportnum = this.getZportrowsize();

    if (colportnum > 0 && rowportnum > 0)
    {
        //hportsize = (this.viewwidth - (this.leftspace + this.rightspace) - ((this.modspace + this.zmodlist[0][0].border)*2)*this.zcolnum)/colportnum;
        //vportsize = (this.viewheight - (this.topspace + this.bottomspace) - ((this.modspace + this.zmodlist[0][0].border)*2)*this.zmodnum)/rowportnum;

        //this.zportsize = (hportsize > vportsize) ? vportsize : hportsize;
        
        var width = 0;
        var height = 0;
        
        var left = this.viewleft + this.leftspace + this.modspace;
        for (var i = 0; i < this.zcolnum; i++)
        {
            var top = this.viewtop + this.topspace + this.modspace;
            for (var j = 0; j < this.zmodnum; j++)
            {
                height = this.zmodlist[i][j].RowNum*this.zportsize + this.zmodlist[i][j].border*2;
                width = this.zmodlist[i][j].ColNum*this.zportsize + this.zmodlist[i][j].border*2;
                
                this.zmodlist[i][j].setModViewRange(left, top, width, height);

                top += this.getZrowsiz(j);    
            }
            
            left += this.getZcolsize(i);
        }        
        this.zdevwidth = left - this.viewleft;
        this.zdevheight = top - this.viewtop;
    }
    
    colportnum = this.getFportcolsize();
    rowportnum = this.getFportrowsize();

    if (colportnum > 0 && rowportnum > 0)
    {
        //hportsize = (this.viewwidth - (this.leftspace + this.rightspace) - ((this.modspace + this.fmodlist[0][0].border)*2)*this.fcolnum)/colportnum;
        //vportsize = (this.viewheight - (this.topspace + this.bottomspace) - ((this.modspace + this.fmodlist[0][0].border)*2)*this.fmodnum)/rowportnum;

        //this.fportsize = (hportsize > vportsize) ? vportsize : hportsize;
        
        var width = 0;
        var height = 0;
        
        var left = this.viewleft + this.leftspace + this.modspace;
        for (var i = 0; i < this.fcolnum; i++)
        {
            var top = this.viewtop + this.topspace + this.modspace;
            for (var j = 0; j < this.fmodnum; j++)
            {
                height = this.fmodlist[i][j].RowNum*this.fportsize + this.fmodlist[i][j].border*2;
                width = this.fmodlist[i][j].ColNum*this.fportsize + this.fmodlist[i][j].border*2;
                
                this.fmodlist[i][j].setModViewRange(left, top, width, height);

                top += this.getFrowsiz(j);
            }
            
            left += this.getFcolsize(i);
        }
        this.fdevwidth = left - this.viewleft;
        this.fdevheight = top - this.viewtop;
    }
}

/*
function getdcolno(colno)
{
    for (var i = 0; i < this.collist.length; i++)
    {
        if (this.collist[i].cn == colno)
            return this.collist[i].dcn;
    }
    
    return "";
}
*/

function disp()
{
    var strHtml = "";
    var div = document.getElementById(this.div);
    
    strHtml += this.getDevHtml();
    strHtml += this.getColsHtml();
//    strHtml += this.getModsHtml();
    
    div.innerHTML = strHtml;    
}

function getDevHtml()
{
    var strHtml = "";
    
    if (this.face)
    {
        strHtml += "<v:Rect";
        //增加显示参数
        strHtml += " style='position:absolute"
        strHtml += ";left="+this.zdevleft  + "px";
        strHtml += ";top="+this.zdevtop  + "px";
        strHtml += ";width="+(this.zdevwidth < 40 ? 40 : this.zdevwidth)  + "px";
        strHtml += ";height="+this.zdevheight  + "px";
        //增加显示参数
        strHtml += "'/>"
    }
    else
    {
        strHtml += "<v:Rect";
        //增加显示参数
        strHtml += " style='position:absolute"
        strHtml += ";left="+this.fdevleft  + "px";
        strHtml += ";top="+this.fdevtop  + "px";
        strHtml += ";width="+this.fdevwidth  + "px";
        strHtml += ";height="+this.fdevheight  + "px";
        //增加显示参数
        strHtml += "'/>"
    }
    
    return strHtml;
}

function getColsHtml()
{
    var strHtml = "";
    var left = 0;
    var top = 0;
    var width = 0;
    var colno = "";

    if (this.face)
    {
        left = this.zdevleft + this.leftspace;
        top = this.colnametop + this.zdevtop;
        
        for (var i = 0; i < this.zcolnum; i++)
        {
            var strtmp = "";
            width = this.getZcolsize(i);
            if(width < 40) width = 40;
            //colno = this.getdcolno(this.zstartcolno + i);
            
            strtmp += "<v:Textbox";
            //增加显示参数
            //strtmp += " insett='5pt,5pt,5pt'"
            strtmp += " style='position:absolute";
            strtmp += ";height=" + this.colnameheight  + "px";
            strtmp += ";width=" + width  + "px";
            strtmp += ";left=" + left  + "px";
            strtmp += ";top=" + top  + "px";
            strtmp += "'>";
            strtmp += "<FONT";
            strtmp += " SIZE=" + this.colnamesize - 1;
            strtmp += ">";
            
            if (this.devtype == 1)
            {
                strtmp += "<a href=javascript:dispCol(" + i + ")>";
                strtmp += "第"+(this.zstartcolno + i)+"列";
                strtmp += "</a>";
            }            
            else
            {
               strtmp += "第"+(this.zstartcolno + i)+"列"; 
            }
            
            strtmp += "</FONT>";
            strtmp += "</v:Textbox>";

            strHtml += strtmp;
            
            left += width;
        }
    }
    else
    {
        left = this.fdevleft + this.leftspace;
        top = this.colnametop + this.fdevtop;
        
        for (var i = 0; i < this.fcolnum; i++)
        {
            var strtmp = "";
            width = this.getFcolsize(i);
            if(width < 40) width = 40;
            //colno = this.getdcolno(this.fstartcolno + i);
            
            strtmp += "<v:Textbox";
            //增加显示参数
            //strtmp += " insett='5pt,5pt,5pt'"
            strtmp += " style='position:absolute";
            strtmp += ";height=" + this.colnameheight  + "px";
            strtmp += ";width=" + width  + "px";
            strtmp += ";left=" + left  + "px";
            strtmp += ";top=" + top  + "px";
            strtmp += "'>";
            strtmp += "<FONT";
            strtmp += " SIZE=" + this.colnamesize - 1;
            strtmp += ">";
            
            if (this.devtype == 1)
            {
                strtmp += "<a href=javascript:dispCol(" + i + ")>";
                strtmp += "第"+(this.fstartcolno + i)+"列";
                strtmp += "</a>";
            }            
            else
            {
               strtmp += "第"+(this.fstartcolno + i)+"列";
            }
            
            strtmp += "</FONT>";
            strtmp += "</v:Textbox>";

            strHtml += strtmp;
            
            left += width;
        }
    }
        
    return strHtml;
}

function getModsHtml()
{
    var strHtml = "";
    
//    strHtml += "<center>";
    
    if (this.face)
    {
        for (var i = 0; i < this.zcolnum; i++)
        {
            for (var j = 0; j < this.zmodnum; j++)
            {
                var strtmp = "";
                
                strtmp += "<div";
                strtmp += " id=\"" + i + "&" + j + "\"";
                strtmp += ">";
                strtmp += "</div>";
                
                /*
                strtmp += this.zmodlist[i][j].getModHtml();
                strtmp += this.zmodlist[i][j].getPortCdHtml();
                strtmp += this.zmodlist[i][j].getPortHtml();
                */
                
                strHtml += strtmp;
            }
        }
    }
    else
    {
        for (var i = 0; i < this.fcolnum; i++)
        {
            for (var j = 0; j < this.fmodnum; j++)
            {
                var strtmp = "";
                
                strtmp += "<div";
                strtmp += " id=\"" + i + "&" + j + "\"";
                strtmp += ">";
                strtmp += "</div>";
                
                /*
                strtmp += this.fmodlist[i][j].getModHtml();
                strtmp += this.fmodlist[i][j].getPortCdHtml();
                strtmp += this.fmodlist[i][j].getPortHtml();
                */
                                
                strHtml += strtmp;
            }
        }
    }

//    strHtml += "</center>";

    return strHtml;
}

function dispAMod(col, row)
{
    var strHtml = "";
    var strtmp = "";
       
    if (this.face)
    {                
        strtmp += this.zmodlist[col][row].getModHtml();
        strtmp += this.zmodlist[col][row].getPortCdHtml();
        strtmp += this.zmodlist[col][row].getPortHtml();
    }
    else
    {
        strtmp += this.fmodlist[col][row].getModHtml();
        strtmp += this.fmodlist[col][row].getPortCdHtml();
        strtmp += this.fmodlist[col][row].getPortHtml();
    }

    var id = col + "&" + row;
    var vdiv = document.getElementById(this.div);
    var div = document.getElementById(id);
    
    if (div && div.parentElement.id == vdiv.id)
    {
        div.innerHTML = strtmp;
    }
    else
    {
        strHtml += "<div";
        strHtml += " id=\"" + id + "\"";
        strHtml += ">";
        strHtml += strtmp;
        strHtml += "</div>";
        vdiv.insertAdjacentHTML("beforeEnd", strHtml);
    }

    return strHtml;
}

function setPortState(listcol, listdz, liststate)
{
    var dzvml;    
    var color;
    var maxportno = this.getMaxPortNo();
    var minportno = this.getMinPortNo();
        
    for (var i = 0; i < listdz.length; i++)
    {
        var id = "";
        if (listcol.length != 0)
        {
            id += listcol[i] + "_";
        }
        
        id += listdz[i];
        
        if (this.face)
        {
            if (listcol[i] < this.zstartcolno || listcol[i] > this.zendcolno)
            {
                continue;
            }
        }
        else
        {
           if (listcol[i] < this.fstartcolno || listcol[i] > this.fendcolno)
            {
                continue;
            } 
        }
        
        if (parseInt(listdz[i]) > maxportno || parseInt(listdz[i]) < minportno)
        {
            continue;
        }
        
        dzvml = document.getElementById(id);
        
        if (dzvml != null)
        {               
            var portinfo = this.getDzColorByPortState(liststate[i])
            
            dzvml.fillcolor = portinfo.color;
            dzvml.title = listdz[i] + " " + portinfo.title;
        }
    }
}

function getDzColorByPortState(state)
{    
    var color = "#ffffff";
    var title = "";
    
    switch (state)
    {
    case enumLineState_idle:
        color = brushIdle;
        title = "空闲";
        break;
    case enumLineState_used:
        color = brushUse;
        title = "占用";
        break;
    case enumLineState_bad:
        color = brushBad;
        title = "坏";
        break;
    case enumLineState_preuse:
        color = brushYz;
        title = "预占";
        break;
    case enumLineState_reserve:
        color = brushIdleFw;
        title = "空闲封网";
        break;
    default:
        break;
    }
    
    var portinfo = new portstate();
    portinfo.color = color;
    portinfo.title = title;
    
    return portinfo;
} 

function getMaxPortNo()
{
    var factcolno;
    var factmodno;
    
    if (this.face)
    {
        factcolno = this.getZColfactNo(this.zendcolno);
        factmodno = this.getModfactNo(this.zmodnum);
        maxportno = this.zmodlist[factcolno][factmodno].StartPortNo + this.zmodlist[factcolno][factmodno].RowNum * this.zmodlist[factcolno][factmodno].ColNum;
    }
    else
    {
        factcolno = this.getFColfactNo(this.fendcolno);
        factmodno = this.getModfactNo(this.fmodnum);
        maxportno = this.fmodlist[factcolno][factmodno].StartPortNo + this.fmodlist[factcolno][factmodno].RowNum * this.fmodlist[factcolno][factmodno].ColNum;
    }
    return maxportno - 1;
}

function getMinPortNo()
{
    var factcolno;
    var factmodno;

    if (this.face)
    {
        factcolno = this.getZColfactNo(this.zstartcolno);
        minportno = this.zmodlist[factcolno][0].StartPortNo;
    }
    else
    {
        factcolno = this.getFColfactNo(this.fstartcolno);
        minportno = this.fmodlist[factcolno][0].StartPortNo;
    }
    return minportno; 
}

function portstate()
{
    this.color = "";
    this.title = "";
}